<template>
    <div class="newsInfo">    
        <h3 class="title">{{newsinfo.title}}</h3>
        <div v-html="newsinfo.content"></div>
        <!-- 评论组件 -->
        <comment :newsid="id"></comment>
    </div>
</template>
<script>
import comment from '../../comment/comment.vue';

export default {
    data(){
        return {
            id:this.$route.params.id,
            newsinfo:{}
        }
    },
    created(){
        this.getNewsinfo();
    },
    methods:{
        getNewsinfo(){
            this.$http.get('api/getnew/'+this.id).then(response =>{
            if(response.body.status ===0){
                // 成功
                // console.log(response.body.message);
                this.newsinfo = response.body.message[0];
                // console.log(response);
            }else{
                // 失败
            }
        })
        }
    },
    components:{
        "comment":comment
    }


    
}
</script>
<style lang="scss" scoped>
    .newsInfo{
        padding: 15px;
        margin-bottom: 40px;
        background: #fff;
        color: #111;
        .title{
            font-size: 18px;
            color: red;
            text-align: center;
            margin: 10px auto;
        }
    }
</style>
